package cn.edu.sdu.java.server.repositorys;

import cn.edu.sdu.java.server.models.Lecture;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface LectureRepository extends JpaRepository<Lecture,Integer> {
    @Query(value = "from Lecture where ?1=0 or ?1=student.personId")
    List<Lecture> findByStudentStudentId(Integer studentId);
    @Query(value = "from Lecture where  ?1=student.personId")
    List<Lecture> findByStudentId(Integer studentId);
    @Query(value = "from Lecture where location=?1 and student.person.num=?2")
    List<Lecture> findByLocationAndUser(String topic,String userNum);
    @Query(value = "from Lecture where student.person.num =?1 and student.person.name=?2 and (?3='' or location=?3) ")
    List<Lecture> findByNumNameLocation(String num,String name,String location);
}
